<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<f:view>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <title>Global Image - Detales da venda</title>
            <link rel="stylesheet" type="text/css" href="/globalimage2/faces/jsfcrud.css" /><%@ include file="/WEB-INF/jspf/AjaxScripts.jspf" %><script type="text/javascript" src="/globalimage2/faces/jsfcrud.js"></script>
        </head>
        <body>
            <%@include file="../../WEB-INF/jspf/header/head.jspf"%>
            <div style="float:left">
                <%@include file="../../WEB-INF/jspf/header/menuDinamico.jspf"%>
            </div>
            <div id="div_content">
                <div class="bgContentTable">
                    <div class="titleTable"><h3>Detalhes da venda</h3></div><br />
                    <h:form>
                        &nbsp;&nbsp;
                        <h:commandLink action="#{venda.createSetup}" value="Novo" />
                        &nbsp;|&nbsp;
                        <h:commandLink action="#{venda.listSetup}" value="Exibir todos"/>

                        <h:panelGroup id="messagePanel" layout="block">
                            <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                        </h:panelGroup>
                        <br/>
                        <h:panelGrid columns="2" style="margin-left: 10px;">
                            <h:outputText value="Cliente:"/>
                            <h:commandLink value="#{venda.venda.clienteId}" action="#{usuario.detailSetup}">
                                <f:param name="jsfcrud.currentVenda" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][venda.venda][venda.converter].jsfcrud_invoke}"/>
                                <f:param name="jsfcrud.currentUsuario" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][venda.venda.clienteId][usuario.converter].jsfcrud_invoke}"/>
                                <f:param name="jsfcrud.relatedController" value="venda"/>
                                <f:param name="jsfcrud.relatedControllerType" value="entidade.controller.JSF.VendaController"/>
                            </h:commandLink>

                            <h:outputText value="Vendedor:"/>
                            <h:commandLink value="#{venda.venda.funcionarioId}" action="#{funcionario.detailSetup}">
                                <f:param name="jsfcrud.currentVenda" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][venda.venda][venda.converter].jsfcrud_invoke}"/>
                                <f:param name="jsfcrud.currentFuncionario" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][venda.venda.funcionarioId][funcionario.converter].jsfcrud_invoke}"/>
                                <f:param name="jsfcrud.relatedController" value="venda"/>
                                <f:param name="jsfcrud.relatedControllerType" value="entidade.controller.JSF.VendaController"/>
                            </h:commandLink>

                            <h:outputText value="Transportador:"/>
                            <c:if test="${venda.venda.transportadorId != null}">
                                <h:commandLink value="#{venda.venda.transportadorId}" action="#{usuario.detailSetup}">
                                    <f:param name="jsfcrud.currentVenda" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][venda.venda][venda.converter].jsfcrud_invoke}"/>
                                    <f:param name="jsfcrud.currentUsuario" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][venda.venda.transportadorId][usuario.converter].jsfcrud_invoke}"/>
                                    <f:param name="jsfcrud.relatedController" value="venda"/>
                                    <f:param name="jsfcrud.relatedControllerType" value="entidade.controller.JSF.VendaController"/>
                                </h:commandLink>
                            </c:if>
                            <c:if test="${venda.venda.transportadorId == null}">
                                <h:outputText value="  ---  "/>
                            </c:if>


                            <h:outputText value="Data da venda:"/>
                            <h:outputText value="#{venda.venda.dataVenda}" title="DataVenda" >
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                            <h:outputText value="Data de entrega:"/>
                            <h:outputText value="#{venda.venda.dataEntrega}" title="DataEntrega" >
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                            <h:outputText value="Data de pagamento:"/>
                            <h:outputText value="#{venda.venda.dataPagamento}" title="DataPagamento" >
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                            <h:outputText value="Descrição:"/>
                            <h:outputText value="#{venda.venda.observacao}" title="Observacao" />
                            <h:outputText value="Valor transporte:"/>
                            <h:outputText value="#{venda.venda.valorTransporte}" title="ValorTransporte" >
                                <f:convertNumber type="currency"/>
                            </h:outputText>
                            <h:outputText value="Seguro transporte:"/>
                            <h:outputText value="#{venda.venda.seguroTransporte}" title="SeguroTransporte">
                                <f:convertNumber type="currency"/>
                            </h:outputText>
                            <h:outputText value="Juros ao Mês:"/>
                            <h:outputText value="#{venda.venda.jurosMes}" title="Juros mês">
                                <f:convertNumber type="percent"/>
                            </h:outputText>

                            <h:outputText value="Produtos Vendidos:" />
                            <h:panelGroup style="margin-left: 10px;">
                                <h:outputText rendered="#{empty venda.venda.produtoVendaCollection}" value="(No Items)"/>
                                <h:dataTable value="#{venda.venda.produtoVendaCollection}" var="item"
                                             border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px;width: 330%;"
                                             rendered="#{not empty venda.venda.produtoVendaCollection}">
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Produto"/>
                                        </f:facet>
                                        <h:commandLink value="#{item.produto.nome}" action="#{produtoVenda.detailSetup}">
                                            <f:param name="jsfcrud.currentVenda" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][venda.venda][venda.converter].jsfcrud_invoke}"/>
                                            <f:param name="jsfcrud.currentProdutoVenda" value="#{jsfcrud_class['entidade.controller.JSF.util.JsfUtil'].jsfcrud_method['getAsConvertedString'][item][produtoVenda.converter].jsfcrud_invoke}"/>
                                            <f:param name="jsfcrud.relatedController" value="venda" />
                                            <f:param name="jsfcrud.relatedControllerType" value="entidade.controller.JSF.VendaController" />
                                        </h:commandLink>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Quantidade"/>
                                        </f:facet>
                                        <h:outputText value="#{item.quantidade}"/>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Preco unt"/>
                                        </f:facet>
                                        <h:outputText value="#{item.precoUnitario}">
                                            <f:convertNumber type="currency"/>
                                        </h:outputText>
                                    </h:column>
                                </h:dataTable>
                            </h:panelGroup>
                            
                            <h:outputText value="Operações extras:" />
                            <h:panelGroup style="margin-left: 10px;">
                                <h:outputText rendered="#{empty venda.venda.opercaoExtraCollection}" value="(No Items)"/>
                                <h:dataTable value="#{venda.venda.opercaoExtraCollection}" var="item"
                                             border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px;width: 330%;"
                                             rendered="#{not empty venda.venda.opercaoExtraCollection}">
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Nome"/>
                                        </f:facet>
                                        <h:outputText value="#{item.operacaoExtraTipoId.nome}"/>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Valor"/>
                                        </f:facet>
                                        <h:outputText value="#{item.valor}">
                                            <f:convertNumber type="currency"/>
                                        </h:outputText>
                                    </h:column>
                                </h:dataTable>
                            </h:panelGroup>

                            <h:outputText value="Parcelas:" />
                            <h:panelGroup style="margin-left: 10px;">
                                <h:outputText rendered="#{empty venda.venda.entradaSaidaCollection}" value="(No Items)"/>
                                <h:dataTable value="#{venda.venda.entradaSaidaCollection}" var="item"
                                             border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px;width: 330%;"
                                             rendered="#{not empty venda.venda.entradaSaidaCollection}">
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Parcela"/>
                                        </f:facet>
                                        <h:outputText value="#{item.parcelaAtual} de #{item.quantidadeParcela}"/>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Vencimento"/>
                                        </f:facet>
                                        <h:outputText value="#{item.dataVencimento}">
                                            <f:convertDateTime pattern="dd / MM / yyyy" />
                                        </h:outputText>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Valor da parcela"/>
                                        </f:facet>
                                        <h:outputText value="#{item.valor}">
                                            <f:convertNumber type="currency"/>
                                        </h:outputText>
                                    </h:column>
                                </h:dataTable>
                            </h:panelGroup>
                            
                            <h:outputText value="Total:"/>
                            <h:outputText value="#{venda.venda.totalVenda}" title="Total" >
                                <f:convertNumber type="currency"/>
                            </h:outputText>
                        </h:panelGrid>
                    </h:form>
                </div>
            </div>
        </body>
    </html>
</f:view>
